home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / vgakit41 / banks.asm next >
Assembly Source File  |  1991-10-02  |  14KB  |  942 lines

  1.  
  2.     include    model.h
  3.  
  4. ;
  5. ;    VGAKIT Version 4.1
  6. ;
  7. ;    Copyright 1988,89,90,91 John Bridges
  8. ;    Free for use in commercial, shareware or freeware applications
  9. ;
  10. ;    BANKS.ASM
  11. ;
  12. .data
  13.  
  14. OSEG    equ    DS:        ;segment override for variable access
  15.  
  16. bankadr    dw    ?
  17. if @Codesize
  18. bankseg    dw    ?
  19. endif
  20.  
  21.     public    curbk
  22.  
  23. curbk    dw    ?
  24.  
  25.     public    vga512,vga1024
  26.  
  27. vga512    dw    ?
  28. vga1024    dw    ?
  29.  
  30.     public    cirrus,everex,paradise,tseng,trident,t8900
  31.     public    ativga,aheada,aheadb,oaktech,video7
  32.     public    chipstech,tseng4,genoa,ncr,compaq,vesa
  33.  
  34. cirrus    dw    ?
  35. everex    dw    ?
  36. paradise dw    ?
  37. tseng    dw    ?
  38. trident    dw    ?
  39. t8900    dw    ?
  40. ativga    dw    ?
  41. aheada    dw    ?
  42. aheadb    dw    ?
  43. oaktech    dw    ?
  44. video7    dw    ?
  45. chipstech dw    ?
  46. tseng4    dw    ?
  47. genoa    dw    ?
  48. ncr    dw    ?
  49. compaq    dw    ?
  50. vesa    dw    ?
  51.  
  52. first    dw    ?        ;flag so whichvga() is only called once
  53. retval    dw    ?        ;first return value from whichvga()
  54.  
  55. vgainfo    label    word
  56. vesaid    db    'VESA'        ; 4 signature bytes
  57. vesaver    dw    ?        ; VESA version number
  58. oemstr    dd    ?        ; Pointer to OEM string
  59. capabil    db    4 dup (?)    ; Capabilities of the video environment
  60. modelst    dd    ?        ; Pointer to supported Super VGA modes
  61.  
  62. vesashift db    0        ; number of bits to shift bank number left
  63.  
  64. .code
  65.  
  66.     public    newbank
  67.     public    whichvga
  68.  
  69. newbank    proc            ;bank number is in AX
  70.     cli
  71.     mov    OSEG[curbk],ax
  72. if @Codesize
  73.     jmp    dword ptr OSEG[bankadr]
  74. else
  75.     jmp    word ptr OSEG[bankadr]
  76. endif
  77.  
  78.  
  79. _tseng::                ;Tseng
  80.     push    ax
  81.     push    dx
  82.     and    al,7
  83.     mov    ah,al
  84.     shl    al,1
  85.     shl    al,1
  86.     shl    al,1
  87.     or    al,ah
  88.     or    al,01000000b
  89.     mov    dx,3cdh
  90.     out    dx,al
  91.     sti
  92.     pop    dx
  93.     pop    ax
  94.     ret
  95.  
  96.  
  97. _tseng4::                ;Tseng 4000 series
  98.     push    ax
  99.     push    dx
  100.     mov    ah,al
  101.     mov    dx,3bfh            ;Enable access to extended registers
  102.     mov    al,3
  103.     out    dx,al
  104.     mov    dl,0d8h
  105.     mov    al,0a0h
  106.     out    dx,al
  107.     and    ah,15
  108.     mov    al,ah
  109.     shl    al,1
  110.     shl    al,1
  111.     shl    al,1
  112.     shl    al,1
  113.     or    al,ah
  114.     mov    dl,0cdh
  115.     out    dx,al
  116.     sti
  117.     pop    dx
  118.     pop    ax
  119.     ret
  120.  
  121.  
  122. _trident::            ;Trident
  123.     push    ax
  124.     push    dx
  125.     mov    dx,3ceh        ;set pagesize to 64k
  126.     mov    al,6
  127.     out    dx,al
  128.     inc    dl
  129.     in    al,dx
  130.     dec    dl
  131.     or    al,4
  132.     mov    ah,al
  133.     mov    al,6
  134.     out    dx,ax
  135.  
  136.     mov    dl,0c4h        ;switch to BPS mode
  137.     mov    al,0bh
  138.     out    dx,al
  139.     inc    dl
  140.     in    al,dx
  141.     dec    dl
  142.  
  143.     mov    ah,byte ptr OSEG[curbk]
  144.     xor    ah,2
  145.     mov    dx,3c4h
  146.     mov    al,0eh
  147.     out    dx,ax
  148.     sti
  149.     pop    dx
  150.     pop    ax
  151.     ret
  152.  
  153.  
  154. _video7::            ;Video 7
  155.     push    ax
  156.     push    dx
  157.     push    cx
  158.     and    ax,15
  159.     mov    ch,al
  160.     mov    dx,3c4h
  161.     mov    ax,0ea06h
  162.     out    dx,ax
  163.     mov    ah,ch
  164.     and    ah,1
  165.     mov    al,0f9h
  166.     out    dx,ax
  167.     mov    al,ch
  168.     and    al,1100b
  169.     mov    ah,al
  170.     shr    ah,1
  171.     shr    ah,1
  172.     or    ah,al
  173.     mov    al,0f6h
  174.     out    dx,al
  175.     inc    dx
  176.     in    al,dx
  177.     dec    dx
  178.     and    al,not 1111b
  179.     or    ah,al
  180.     mov    al,0f6h
  181.     out    dx,ax
  182.     mov    ah,ch
  183.     mov    cl,4
  184.     shl    ah,cl
  185.     and    ah,100000b
  186.     mov    dl,0cch
  187.     in    al,dx
  188.     mov    dl,0c2h
  189.     and    al,not 100000b
  190.     or    al,ah
  191.     out    dx,al
  192.     sti
  193.     pop    cx
  194.     pop    dx
  195.     pop    ax
  196.     ret
  197.  
  198.  
  199. _paradise::            ;Paradise
  200.     push    ax
  201.     push    dx
  202.     mov    dx,3ceh
  203.     mov    ax,50fh        ;turn off write protect on VGA registers
  204.     out    dx,ax
  205.     mov    ah,byte ptr OSEG[curbk]
  206.     shl    ah,1        ;change 64k bank number into 4k bank number
  207.     shl    ah,1
  208.     shl    ah,1
  209.     shl    ah,1
  210.     mov    al,9
  211.     out    dx,ax
  212.     sti
  213.     pop    dx
  214.     pop    ax
  215.     ret
  216.  
  217.  
  218. _chipstech::            ;Chips & Tech
  219.     push    ax
  220.     push    dx
  221.     mov    dx,46e8h    ;place chip in setup mode
  222.     mov    ax,1eh
  223.     out    dx,ax
  224.     mov    dx,103h        ;enable extended registers
  225.     mov    ax,0080h
  226.     out    dx,ax
  227.     mov    dx,46e8h    ;bring chip out of setup mode
  228.     mov    ax,0eh
  229.     out    dx,ax
  230.     mov    ah,byte ptr OSEG[curbk]
  231.     shl    ah,1        ;change 64k bank number into 16k bank number
  232.     shl    ah,1
  233.     mov    al,10h
  234.     mov    dx,3d6h
  235.     out    dx,ax
  236.     sti
  237.     pop    dx
  238.     pop    ax
  239.     ret
  240.  
  241.  
  242. _ativga::            ;ATI VGA Wonder
  243.     push    ax
  244.     push    dx
  245.     mov    ah,al
  246.     mov    dx,1ceh
  247.     mov    al,0b2h
  248.     out    dx,al
  249.     inc    dl
  250.     in    al,dx
  251.     shl    ah,1
  252.     and    al,0e1h
  253.     or    ah,al
  254.     mov    al,0b2h
  255.     dec    dl
  256.     out    dx,ax
  257.     sti
  258.     pop    dx
  259.     pop    ax
  260.     ret
  261.  
  262.  
  263. _everex::            ;Everex
  264.     push    ax
  265.     push    dx
  266.     push    cx
  267.     mov    cl,al
  268.     mov    dx,3c4h
  269.     mov    al,8
  270.     out    dx,al
  271.     inc    dl
  272.     in    al,dx
  273.     dec    dl
  274.     shl    al,1
  275.     shr    cl,1
  276.     rcr    al,1
  277.     mov    ah,al
  278.     mov    al,8
  279.     out    dx,ax
  280.     mov    dl,0cch
  281.     in    al,dx
  282.     mov    dl,0c2h
  283.     and    al,0dfh
  284.     shr    cl,1
  285.     jc    nob2
  286.     or    al,20h
  287. nob2:    out    dx,al
  288.     sti
  289.     pop    cx
  290.     pop    dx
  291.     pop    ax
  292.     ret
  293.  
  294.  
  295. _aheada::            ;Ahead Systems Ver A
  296.     push    ax
  297.     push    dx
  298.     push    cx
  299.     mov    ch,al
  300.     mov    dx,3ceh        ;Enable extended registers
  301.     mov    ax,200fh
  302.     out    dx,ax
  303.     mov    dl,0cch        ;bit 0
  304.     in    al,dx
  305.     mov    dl,0c2h
  306.     and    al,11011111b
  307.     shr    ch,1
  308.     jnc    skpa
  309.     or    al,00100000b
  310. skpa:    out    dx,al
  311.     mov    dl,0cfh        ;bits 1,2,3
  312.     mov    al,0
  313.     out    dx,al
  314.     inc    dx
  315.     in    al,dx
  316.     dec    dx
  317.     and    al,11111000b
  318.     or    al,ch
  319.     mov    ah,al
  320.     mov    al,0
  321.     out    dx,ax
  322.     sti
  323.     pop    cx
  324.     pop    dx
  325.     pop    ax
  326.     ret
  327.  
  328.  
  329. _aheadb::            ;Ahead Systems Ver A
  330.     push    ax
  331.     push    dx
  332.     push    cx
  333.     mov    ch,al
  334.     mov    dx,3ceh        ;Enable extended registers
  335.     mov    ax,200fh
  336.     out    dx,ax
  337.     mov    ah,ch
  338.     mov    cl,4
  339.     shl    ah,cl
  340.     or    ah,ch
  341.     mov    al,0dh
  342.     out    dx,ax
  343.     sti
  344.     pop    cx
  345.     pop    dx
  346.     pop    ax
  347.     ret
  348.  
  349.  
  350. _oaktech::            ;Oak Technology Inc OTI-067
  351.     push    ax
  352.     push    dx
  353.     and    al,15
  354.     mov    ah,al
  355.     shl    al,1
  356.     shl    al,1
  357.     shl    al,1
  358.     shl    al,1
  359.     or    ah,al
  360.     mov    al,11h
  361.     mov    dx,3deh
  362.     out    dx,ax
  363.     sti
  364.     pop    dx
  365.     pop    ax
  366.     ret
  367.  
  368. _genoa::            ;GENOA GVGA
  369.     push    ax
  370.     push    dx
  371.     mov    ah,al
  372.     shl    al,1
  373.     shl    al,1
  374.     shl    al,1
  375.     or    ah,al
  376.     mov    al,6
  377.     or    ah,40h
  378.     mov    dx,3c4h
  379.     out    dx,ax
  380.     sti
  381.     pop    dx
  382.     pop    ax
  383.     ret
  384.  
  385. _ncr::                ;NCR 77C22E
  386.     push    ax
  387.     push    dx
  388.     shl    al,1        ;change 64k bank number into 16k bank number
  389.     shl    al,1
  390.     mov    ah,al
  391.     mov    al,18h
  392.     mov    dx,3c4h
  393.     out    dx,ax
  394.     mov    ax,19h
  395.     out    dx,ax
  396.     sti
  397.     pop    dx
  398.     pop    ax
  399.     ret
  400.  
  401. _compaq::            ;Compaq
  402.     push    ax
  403.     push    dx
  404.     mov    dx,3ceh
  405.     mov    ax,50fh        ;unlock extended registers
  406.     out    dx,ax
  407.     mov    ah,byte ptr OSEG[curbk]
  408.     shl    ah,1        ;change 64k bank number into 4k bank number
  409.     shl    ah,1
  410.     shl    ah,1
  411.     shl    ah,1
  412.     mov    al,45h
  413.     out    dx,ax
  414.     sti
  415.     pop    dx
  416.     pop    ax
  417.     ret
  418.  
  419. _vesa::                ;Vesa SVGA interface
  420.     push    ax
  421.     push    bx
  422.     push    cx
  423.     push    dx
  424.     mov    cl,[vesashift]
  425.     shl    ax,cl
  426.     mov    dx,ax
  427.     xor    bx,bx
  428.     mov    ax,4f05h
  429.     int    10h
  430.     sti
  431.     pop    dx
  432.     pop    cx
  433.     pop    bx
  434.     pop    ax
  435.     ret
  436.  
  437. _nobank::
  438.     sti
  439.     ret
  440.  
  441. newbank    endp
  442.  
  443. bkadr    macro    func
  444.     mov    [func],1
  445.     mov    [bankadr],offset _&func
  446. if @Codesize
  447.     mov    [bankseg],seg _&func
  448. endif
  449.     endm
  450.  
  451. nojmp    macro
  452.     local    lbl
  453.     jmp    lbl
  454. lbl:
  455.     endm
  456.  
  457.  
  458. whichvga proc    uses si di
  459.     local    vesabuf[256]:byte
  460.  
  461.     cmp    [first],'FI'
  462.     jnz    gotest
  463.     mov    ax,[retval]
  464.     ret
  465. gotest:    mov    [bankadr],offset _nobank
  466. if @Codesize
  467.     mov    [bankseg],seg _nobank
  468. endif
  469.     xor    ax,ax
  470.     mov    [curbk],ax
  471.     mov    [vga512],ax
  472.     mov    [vga1024],ax
  473.     mov    [cirrus],ax
  474.     mov    [everex],ax
  475.     mov    [paradise],ax
  476.     mov    [tseng],ax
  477.     mov    [trident],ax
  478.     mov    [t8900],ax
  479.     mov    [ativga],ax
  480.     mov    [aheada],ax
  481.     mov    [aheadb],ax
  482.     mov    [oaktech],ax
  483.     mov    [video7],ax
  484.     mov    [chipstech],ax
  485.     mov    [tseng4],ax
  486.     mov    [genoa],ax
  487.     mov    [ncr],ax
  488.     mov    [compaq],ax
  489.     mov    [vesa],ax
  490.     mov    [first],'FI'
  491.  
  492.     mov    ax,ss
  493.     mov    es,ax
  494.     lea    di,vesabuf[0]
  495.     mov    ax,4f00h
  496.     int    10h
  497.     cmp    ax,4fh
  498.     jnz    novesa
  499.     lea    si,vesabuf[0]
  500.     mov    di,offset vgainfo
  501.     mov    ax,ds
  502.     mov    es,ax
  503.     push    ds
  504.     mov    ax,ss
  505.     mov    ds,ax
  506.     mov    cx,7
  507.     cld
  508.     rep    movsw
  509.     pop    ds
  510.     bkadr    vesa
  511.     mov    [vga512],1
  512.     mov    [vga1024],1
  513. ;    jmp    fini
  514.  
  515. novesa:    mov    si,1
  516.     mov    ax,0c000h
  517.     mov    es,ax
  518.     cmp    word ptr es:[40h],'13'    ;ATI Signiture on the Video BIOS
  519.     jnz    noati
  520.     bkadr    ativga
  521.     cli
  522.     mov    dx,1ceh
  523.     mov    al,0bbh
  524.     out    dx,al
  525.     inc    dl
  526.     in    al,dx
  527.     sti
  528.     and    al,20h
  529.     jz    no512
  530.     mov    [vga512],1
  531. no512:    jmp    fini
  532.  
  533. noati:    mov    ax,7000h        ;Test for Everex
  534.     xor    bx,bx
  535.     cld
  536.     int    10h
  537.     cmp    al,70h
  538.     jnz    noev
  539.     bkadr    everex
  540.     and    ch,11000000b        ;how much memory on board
  541.     jz    skp
  542.     mov    [vga512],1
  543. skp:                    ;fall through for Everex boards using Trident or Tseng4000
  544.  
  545. noev:    mov    ax,0bf03h        ;Test for Compaq
  546.     xor    bx,bx
  547.     mov    cx,bx
  548.     int    10h
  549.     cmp    ax,0bf03h
  550.     jnz    nocp
  551.     test    cl,40h            ;is 640x480x256 available?
  552.     jz    nocp
  553.     bkadr    compaq
  554.     mov    [vga512],1
  555.     jmp    fini
  556.  
  557. nocp:    mov    dx,3c4h            ;Test for NCR 77C22E
  558.     mov    ax,0ff05h
  559.     call    _isport2
  560.     jnz    noncr
  561.     mov    ax,5            ;Disable extended registers
  562.     out    dx,ax
  563.     mov    ax,0ff10h        ;Try to write to extended register 10
  564.     call    _isport2        ;If it writes then not NCR
  565.     jz    noncr
  566.     mov    ax,105h            ;Enable extended registers
  567.     out    dx,ax
  568.     mov    ax,0ff10h
  569.     call    _isport2
  570.     jnz    noncr            ;If it does NOT write then not NCR
  571.     bkadr    ncr
  572.     mov    [vga512],1
  573.     jmp    fini
  574.  
  575. noncr:    mov    dx,3c4h            ;Test for Trident
  576.     mov    al,0bh
  577.     out    dx,al
  578.     inc    dl
  579.     in    al,dx
  580.     cmp    al,06h
  581.     ja    notri
  582.     cmp    al,2
  583.     jb    notri
  584.     bkadr    trident
  585.     cmp    al,3
  586.     jb    no89
  587.     mov    [t8900],1
  588.     mov    dx,3d5h
  589.     mov    al,1fh
  590.     out    dx,al
  591.     inc    dx
  592.     in    al,dx
  593.     and    al,3
  594.     cmp    al,1
  595.     jb    notmem
  596.     mov    [vga512],1
  597.     je    notmem
  598.     mov    [vga1024],1
  599. notmem:    jmp    fini
  600.  
  601. no89:    mov    [vga512],1
  602.     jmp    fini
  603.  
  604. notri:    mov    ax,6f00h        ;Test for Video 7
  605.     xor    bx,bx
  606.     cld
  607.     int    10h
  608.     cmp    bx,'V7'
  609.     jnz    nov7
  610.     bkadr    video7
  611.     mov    ax,6f07h
  612.     cld
  613.     int    10h
  614.     and    ah,7fh
  615.     cmp    ah,1
  616.     jbe    skp2
  617.     mov    [vga512],1
  618. skp2:    cmp    ah,3
  619.     jbe    skp3
  620.     mov    [vga1024],1
  621. skp3:    jmp    fini
  622.  
  623. nov7:    mov    dx,3d4h            ;Test for GENOA GVGA
  624.     mov    ax,032eh        ;check for Herchi Register
  625.     call    _isport2
  626.     jnz    nogn
  627.     mov    dx,3c4h            ;check for memory segment register
  628.     mov    ax,3f06h
  629.     call    _isport2
  630.     jnz    nogn
  631.     bkadr    genoa
  632.     mov    [vga512],1
  633.     jmp    fini
  634.  
  635. nogn:    call    _cirrus            ;Test for Cirrus
  636.     cmp    [cirrus],0
  637.     je    noci
  638.     jmp    fini
  639.  
  640. noci:    mov    dx,3ceh            ;Test for Paradise
  641.     mov    al,9            ;check Bank switch register
  642.     out    dx,al
  643.     inc    dx
  644.     in    al,dx
  645.     dec    dx
  646.     or    al,al
  647.     jnz    nopd
  648.  
  649.     mov    ax,50fh            ;turn off write protect on VGA registers
  650.     out    dx,ax
  651.     mov    dx,offset _pdrsub
  652.     mov    cx,1
  653.     call    _chkbk
  654.     jc    nopd            ;if bank 0 and 1 same not paradise
  655.     bkadr    paradise
  656.     mov    dx,3ceh
  657.     mov    al,0bh            ;512k detect from Bob Berry
  658.     out    dx,al
  659.     inc    dx
  660.     in    al,dx
  661.     test    al,80h            ;if top bit set then 512k
  662.     jz    nop512
  663.     mov    [vga512],1
  664. nop512:    jmp    fini
  665.  
  666. nopd:    mov    ax,5f00h        ;Test for Chips & Tech
  667.     xor    bx,bx
  668.     cld
  669.     int    10h
  670.     cmp    al,5fh
  671.     jnz    noct
  672.     bkadr    chipstech
  673.     cmp    bh,1
  674.     jb    skp4
  675.     mov    [vga512],1
  676. skp4:    jmp    fini
  677.  
  678. noct:    mov    ch,0
  679.     mov    dx,3d4h            ;check for Tseng 4000 series
  680.     mov    ax,0f33h
  681.     call    _isport2
  682.     jnz    not4
  683.     mov    ch,1
  684.  
  685.     mov    dx,3bfh            ;Enable access to extended registers
  686.     mov    al,3
  687.     out    dx,al
  688.     mov    dx,3d8h
  689.     mov    al,0a0h
  690.     out    dx,al
  691.     jmp    short yes4
  692.  
  693. not4:    mov    dx,3d4h            ;Test for Tseng 3000 or 4000
  694.     mov    ax,1f25h        ;is the Overflow High register there?
  695.     call    _isport2
  696.     jnz    nots
  697.     mov    al,03fh            ;bottom six bits only
  698.     jmp    short yes3
  699. yes4:    mov    al,0ffh
  700. yes3:    mov    dx,3cdh            ;test bank switch register
  701.     call    _isport1
  702.     jnz    nots
  703.     bkadr    tseng
  704.     cmp    ch,0
  705.     jnz    t4mem
  706.     mov    [vga512],1
  707.     jmp    fini
  708.  
  709. t4mem:    mov    dx,3d4h            ;Tseng 4000 memory detect 1meg
  710.     mov    al,37h
  711.     out    dx,al
  712.     inc    dx
  713.     in    al,dx
  714.     test    al,1000b        ;if using 64kx4 RAMs then no more than 256k
  715.     jz    nomem
  716.     and    al,3
  717.     cmp    al,1            ;if 8 bit wide bus then only two 256kx4 RAMs
  718.     jbe    nomem
  719.     mov    [vga512],1
  720.     cmp    al,2            ;if 16 bit wide bus then four 256kx4 RAMs
  721.     je    nomem
  722.     mov    [vga1024],1        ;full meg with eight 256kx4 RAMs
  723. nomem:    bkadr    tseng4
  724.     jmp    short fini
  725.  
  726. nots:
  727.     mov    dx,3ceh            ;Test for Above A or B chipsets
  728.     mov    ax,200fh
  729.     out    dx,ax
  730.     inc    dx
  731.     nojmp
  732.     in    al,dx
  733.     cmp    al,21h
  734.     jz    verb
  735.     cmp    al,20h
  736.     jnz    noab
  737.     bkadr    aheada
  738.     mov    [vga512],1
  739.     jmp    short fini
  740.  
  741. verb:    bkadr    aheadb
  742.     mov    [vga512],1
  743.     jmp    short fini
  744.  
  745. noab:    mov    dx,3deh            ;Test for Oak Technology
  746.     mov    ax,0ff11h        ;look for bank switch register
  747.     call    _isport2
  748.     jnz    nooak
  749.     bkadr    oaktech
  750.     mov    al,0dh
  751.     out    dx,al
  752.     inc    dx
  753.     nojmp
  754.     in    al,dx
  755.     test    al,80h
  756.     jz    no4ram
  757.     mov    [vga512],1
  758. no4ram:    jmp    short fini
  759.  
  760. nooak:    mov    si,0
  761.  
  762. fini:    mov    ax,si
  763.     mov    [retval],ax
  764.     ret
  765. whichvga endp
  766.  
  767.  
  768. _cirrus    proc    near
  769.     mov    dx,3d4h        ; assume 3dx addressing
  770.     mov    al,0ch        ; screen a start address hi
  771.     out    dx,al        ; select index
  772.     inc    dx        ; point to data
  773.     mov    ah,al        ; save index in ah
  774.     in    al,dx        ; get screen a start address hi
  775.     xchg    ah,al        ; swap index and data
  776.     push    ax        ; save old value
  777.     push    dx        ; save crtc address
  778.     xor    al,al        ; clear crc
  779.     out    dx,al        ; and out to the crtc
  780.  
  781.     mov    al,1fh        ; Eagle ID register
  782.     dec    dx        ; back to index
  783.     out    dx,al        ; select index
  784.     inc    dx        ; point to data
  785.     in    al,dx        ; read the id register
  786.     mov    bh,al        ; and save it in bh
  787.  
  788.     mov    cl,4        ; nibble swap rotate count
  789.     mov    dx,3c4h        ; sequencer/extensions
  790.     mov    bl,6        ; extensions enable register
  791.  
  792.     ror    bh,cl        ; compute extensions disable value
  793.     mov    ax,bx        ; extensions disable
  794.     out    dx,ax        ; disable extensions
  795.     inc    dx        ; point to data
  796.     in    al,dx        ; read enable flag
  797.     or    al,al        ; disabled ?
  798.     jnz    exit        ; nope, not an cirrus
  799.  
  800.     ror    bh,cl        ; compute extensions enable value
  801.     dec    dx        ; point to index
  802.     mov    ax,bx        ; extensions enable
  803.     out    dx,ax        ; enable extensions
  804.     inc    dx        ; point to data
  805.     in    al,dx        ; read enable flag
  806.     cmp    al,1        ; enabled ?
  807.     jne    exit        ; nope, not an cirrus
  808.     mov    [cirrus],1
  809.     mov    [bankadr],offset _nobank
  810. if @Codesize
  811.     mov    [bankseg],seg _nobank
  812. endif
  813. exit:    pop    dx        ; restore crtc address
  814.     dec    dx        ; point to index
  815.     pop    ax        ; recover crc index and data
  816.     out    dx,ax        ; restore crc value
  817.     ret
  818. _cirrus    endp
  819.  
  820. _chkbk    proc    near        ;bank switch check routine
  821.     mov    di,0b800h
  822.     mov    es,di
  823.     xor    di,di
  824.     mov    bx,1234h
  825.     call    _gochk
  826.     jnz    badchk
  827.     mov    bx,4321h
  828.     call    _gochk
  829.     jnz    badchk
  830.     clc
  831.     ret
  832. badchk:    stc
  833.     ret
  834. _chkbk    endp
  835.  
  836. _gochk    proc    near
  837.     push    si
  838.     mov    si,bx
  839.  
  840.     mov    al,cl
  841.     call    dx
  842.     xchg    bl,es:[di]
  843.     mov    al,ch
  844.     call    dx
  845.     xchg    bh,es:[di]
  846.  
  847.     xchg    si,bx
  848.  
  849.     mov    al,cl
  850.     call    dx
  851.     xor    bl,es:[di]
  852.     mov    al,ch
  853.     call    dx
  854.     xor    bh,es:[di]
  855.  
  856.     xchg    si,bx
  857.  
  858.     mov    al,ch
  859.     call    dx
  860.     mov    es:[di],bh
  861.     mov    al,cl
  862.     call    dx
  863.     mov    es:[di],bl
  864.  
  865.     mov    al,0
  866.     call    dx
  867.     or    si,si
  868.     pop    si
  869.     ret
  870. _gochk    endp
  871.  
  872.  
  873. _pdrsub    proc    near        ;Paradise
  874.     push    dx
  875.     mov    ah,al
  876.     mov    dx,3ceh
  877.     mov    al,9
  878.     out    dx,ax
  879.     pop    dx
  880.     ret
  881. _pdrsub    endp
  882.  
  883.  
  884. _isport2 proc    near
  885.     push    bx
  886.     mov    bx,ax
  887.     out    dx,al
  888.     mov    ah,al
  889.     inc    dx
  890.     in    al,dx
  891.     dec    dx
  892.     xchg    al,ah
  893.     push    ax
  894.     mov    ax,bx
  895.     out    dx,ax
  896.     out    dx,al
  897.     mov    ah,al
  898.     inc    dx
  899.     in    al,dx
  900.     dec    dx
  901.     and    al,bh
  902.     cmp    al,bh
  903.     jnz    noport
  904.     mov    al,ah
  905.     mov    ah,0
  906.     out    dx,ax
  907.     out    dx,al
  908.     mov    ah,al
  909.     inc    dx
  910.     in    al,dx
  911.     dec    dx
  912.     and    al,bh
  913.     cmp    al,0
  914. noport:    pop    ax
  915.     out    dx,ax
  916.     pop    bx
  917.     ret
  918. _isport2 endp
  919.  
  920. _isport1 proc    near
  921.     mov    ah,al
  922.     in    al,dx
  923.     push    ax
  924.     mov    al,ah
  925.     out    dx,al
  926.     in    al,dx
  927.     and    al,ah
  928.     cmp    al,ah
  929.     jnz    noport
  930.     mov    al,0
  931.     out    dx,al
  932.     in    al,dx
  933.     and    al,ah
  934.     cmp    al,0
  935. noport:    pop    ax
  936.     out    dx,al
  937.     ret
  938. _isport1 endp
  939.  
  940.     end
  941.  
  942.